package com.sjksy.demo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sjksy.demo.domain.FinanceSummary;
import com.sjksy.demo.msmapper.ledger.FinanceSummaryMsMapper;
import com.sjksy.demo.msmapper.ledger.LedgerMsMapper;
import com.sjksy.demo.service.FinanceSummaryService;
import com.sjksy.demo.mapper.FinanceSummaryMapper;
import com.sjksy.demo.vo.ledger.LedgerBranchStatisticVo;
import jakarta.annotation.Resource;
import org.springframework.data.annotation.ReadOnlyProperty;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
* @author guyueyuan
* @description 针对表【finance_summary】的数据库操作Service实现
* @createDate 2024-12-11 15:37:02
*/
@Service
public class FinanceSummaryServiceImpl extends ServiceImpl<FinanceSummaryMapper, FinanceSummary>
    implements FinanceSummaryService{

    @Resource
    FinanceSummaryMapper financeSummaryMapper;
    @Resource
    FinanceSummaryMsMapper financeSummaryMsMapper;

    /**
     * 插入分公司的上月销售信息到总账
     * @param ledgerBranchStatisticVoList 分公司上月销售信息统计
     * */
    @Transactional
    @Override
    public boolean recordStatisticBranchLedger(List<LedgerBranchStatisticVo> ledgerBranchStatisticVoList) {
        for (LedgerBranchStatisticVo ledgerBranchStatisticVo : ledgerBranchStatisticVoList) {
            FinanceSummary financeSummary = financeSummaryMsMapper.VoStatisticBranchLedgerToFinanceSummary(ledgerBranchStatisticVo);
            financeSummary.setRecordTime(new Date());
            if(financeSummaryMapper.insert(financeSummary)<=0){
                return false;
            }
        }
        return true;
    }
}




